home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
science
/
sm32a.zip
/
LIBRARY
/
PLOT0.LI
< prev
next >
Wrap
Text File
|
1994-05-11
|
935b
|
34 lines
# plot(y,x)
# plots a function of y=y(x)
# on xy-plane by default xmin:=-5, xmax:=5, ymin:=-5, ymax:=5
# e.g. plot(sin(x),x)
plot(y_, x_, xmin_, xmax_, ymin_, ymax_, texstep_) := block(numeric:=on,
graph,
dx:=(xmax-xmin)/getmaxx,
dy:=(ymax-ymin)/getmaxy,
y0:=getmaxy+(ymin)/dy,
x0:=-xmin/dx,
xstep:=dx*texstep,
line(0,y0,getmaxx,y0),
moveto(0,y0+20),
writes(xmin),
moveto(getmaxx-30,y0+20),
writes(xmax),
line(x0,0,x0,getmaxy),
moveto(x0-20,0),
writes(ymax),
moveto(x0-20,getmaxy-20),
writes(ymin),
setcolor(14),
moveto(0,getmaxy-(subs(y,x=xmin)-ymin)/dy),
do( lineto((x-xmin)/dx,getmaxy-(y-ymin)/dy),
x,xmin,xmax,xstep),
numeric:=off,
readchar,
text,
local(x0,y0,dx,dy,xstep))
plot(y_, x_, xmin_, xmax_, ymin_, ymax_) := plot(y,x,xmin,xmax,ymin,ymax,10)
plot(y_, x_, xmin_, xmax_) := plot(y,x,xmin,xmax,-5,5,10)
plot(y_, x_) := plot(y,x,-5,5,-5,5,10)